<article class="module width_full">
    <header>
        <h3 class="tabs_involved">发放详情</h3>
        <ul class="tabs">
            <form action='{url:/sellercoupon/coupon_detail}' method='get'>
                <input type='hidden' name='controller' value='sellercoupon'/>
                <input type='hidden' name='action' value='coupon_detail'/>
                <input type='hidden' name='id' id="id" value='{$_GET['id']}'/>
                <li class="operating">
                    <div class="search f_l">
                        状态 <select name="status" id="status">
                            <option value="">请选择</option>
                            <option value="1" {if:$_GET['status']==1}selected{/if}>未发放</option>
                            <option value="2" {if:$_GET['status']==2}selected{/if}>未使用</option>
                            <option value="3" {if:$_GET['status']==3}selected{/if}>已使用</option>
                            <option value="4" {if:$_GET['status']==4}selected{/if}>已过期</option>
                            <option value="5" {if:$_GET['status']==5}selected{/if}>退款中</option>
                            <option value="6" {if:$_GET['status']==6}selected{/if}>已退款</option>
                            </select>
                           <select name="user_type" id="user_type">
                               <option value="1" {if:$_GET['user_type']==1}selected{/if}>用户名称</option>
                               <option value="2" {if:$_GET['user_type']==2}selected{/if}>用户编号</option>
                           </select>
                        <input type="text"  name='user_info' value="{$_GET['user_info']}"/>
                        订单号
                        <input type="text"  name='order_no' value="{$_GET['order_no']}"/>
                        券编号
                        <input type="text"  name='code' value="{$_GET['code']}"/>
                        <button class="btn"><span>查 询</span></button>
                    </div>
                </li>
                <li><button class="btn" onclick="Report()"><span>导出Excel</span></button></li>
            </form>
        </ul>
    </header>

    <table class="tablesorter" cellspacing="0">
        <thead>
        <tr>
            <th>券编号</th>
            <th>状态</th>
            <th>发放时间</th>
            <th>用户名称</th>
            <th>用户编号</th>

            <th>使用时间</th>
            <th>备注</th>
        </tr>
        </thead>
        {foreach:items = $this->couponHandle->find()}
        <tr>
            <td> {$item['code']}</td>
            <td>
                {if:$item['status']==1}
                未发放
                {elseif:$item['status']==2}
                未使用
                {elseif:$item['status']==3}
                已使用
                {elseif:$item['status']==4}
                已过期
                {elseif:$item['status']==5}
                退款中
                {elseif:$item['status']==6}
                已退款
                {/if}</td>
            <td> {$item['redeem_time']}</td>
            <td>{$user_info[$item['user_id']]['true_name']}</td>
            <td>{$user_info[$item['user_id']]['username']}</td>
            <td>{$item['use_time']}</td>
            <td>{if:$item['order_no']}使用订单：{$item['order_no']}{/if} {if:$item['receive_order_no']}领券订单：{$item['receive_order_no']}{/if}{$item['remark']}</td>
        </tr>
        {/foreach}
        </thead>
        <tbody>
        {set:$page= (isset($_GET['page'])&&(intval($_GET['page'])>0))?intval($_GET['page']):1;}
        {set:$seller_id = $this->seller['seller_id']}
        </tbody>
    </table>

    {$this->couponHandle->getPageBar()}
</article>
<script>
    //生成 Excel并下载
    function Report() {
        var url = '{url:/sellercoupon/coupon_detail_report/id/@id@}';
        var id = $('#id').val();
        url = url.replace("@id@", id);
        window.open(url);
        return false;
    }
</script>